<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>单位换算</title>
		<script src="https://lf26-cdn-tos.bytecdntp.com/cdn/expire-1-M/vue/2.6.14/vue.min.js"></script>

	</head>
	<body>
		<div id="app">
			公里: <input type="text" v-model="kilometer" />
			<br /><br />
			英里: <input type="text" v-model="mile" />
		</div>

		<script>
			var app = new Vue({
				el: '#app',
				data() {
					return {
						kilometer: 0,
						mile: 0
					}
				},
				//监听属性
				watch: {
					kilometer: function() {
						this.mile = this.kilometer * 0.621371192237;
					},
					
					mile: function() {
						this.kilometer = this.mile / 0.621371192237;
					}
				}
			});
		</script>
	</body>
</html>
